package com.wan37.client.message.received;

import com.google.protobuf.Message;
import com.wan37.client.handler.ClientHandler;
import com.wan37.protobuf.constant.Common;
import com.wan37.protobuf.constant.PtoNum;
import com.wan37.protobuf.message.client2server.game.GameServerResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author : luoyong
 * @date : 2020-07-01 16:20
 **/
@Component(PtoNum.AOIBROADCASTRESPONSE + "")
public class AoiBroadcastResponse implements ReceiveMsg {
    private final static Logger logger = LoggerFactory.getLogger(AoiBroadcastResponse.class);
    private ClientHandler clientHandler = ClientHandler.getInstance();

    @Override
    public void execute(Message msg) {
        GameServerResponse.AoiBroadcastResponse aoiBroadcastResponse = (GameServerResponse.AoiBroadcastResponse) msg;
        int code = aoiBroadcastResponse.getCode();
        switch (code) {
            case Common.SERVER_MONSTER_REVERT:
                clientHandler.updateAOIAllRole(aoiBroadcastResponse.getAllRoleList());
                logger.info(aoiBroadcastResponse.getAllRole(0).getNickname() + " boss更新成功！");
                break;
            case Common.SERVER_AUTO_HP_REVERT:
                clientHandler.updateAOIAllRole(aoiBroadcastResponse.getAllRoleList());
                logger.info(aoiBroadcastResponse.getAllRole(0).getNickname() + " 用户实体Hp更新成功！");
                break;
            case Common.GAME_ROLE_SUCCESS:
                clientHandler.updateAOIAllRole(aoiBroadcastResponse.getAllRoleList());
                logger.info("有用户实体信息更新！");
                break;
            case Common.IRONY_USE:
                clientHandler.updateAOIAllRole(aoiBroadcastResponse.getAllRoleList());
                logger.info("嘲讽技能的使用！");
                break;
            case Common.IRONY_CANCEL:
                clientHandler.updateAOIAllRole(aoiBroadcastResponse.getAllRoleList());
                logger.info("嘲讽技能的取消！");
                break;
            default:
                break;
        }
    }
}
